package com.mission.schedule.CommonDialog;

import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.StyleRes;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.mission.schedule.R;
import com.mission.schedule.constants.ShareFile;
import com.mission.schedule.service.LoginDownDataService;
import com.mission.schedule.utils.SharedPrefUtil;

/**
 * 登录下载对话框(登录使用)
 * Created by liwei on 2017/4/18.
 */

public class LoginDownErrorServiceDialog extends Dialog {

    SharedPrefUtil sharedPrefUtil = null;
    Context context;
    WindowManager windowManager;

    public LoginDownErrorServiceDialog(@NonNull final Context context, @StyleRes int themeResId, final WindowManager windowManager) {
        super(context, themeResId);
        this.context = context;
        this.windowManager = windowManager;


        setCancelable(false);

        View view = LayoutInflater.from(context).inflate(R.layout.logindown_error_dialog, null);
        setContentView(view);



        sharedPrefUtil = new SharedPrefUtil(context, ShareFile.USERFILE);

        view.findViewById(R.id.sjxf).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                ServerDataDownLocalServiceDialog serverDataDownLocalServiceDialog = new ServerDataDownLocalServiceDialog(context, R.style.dialog_translucent, windowManager);
                serverDataDownLocalServiceDialog.show();
            }
        });

        view.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });


    }

    @Override
    public void dismiss() {
        super.dismiss();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Window window = getWindow();
        window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN | WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
        WindowManager.LayoutParams params = window.getAttributes();
        params.width = ViewGroup.LayoutParams.MATCH_PARENT;
        params.height = ViewGroup.LayoutParams.MATCH_PARENT;
        params.alpha = 0.92f;
        params.gravity = Gravity.CENTER;
        window.setAttributes(params);// 设置生效
        window.setGravity(Gravity.CENTER);
    }


}
